#include <iostream>
#include <vector>
using namespace std;

class Solution
{
public:
    int maxArea(vector<int>& height)
    {
        int left = 0, right = height.size() - 1;
        int ret = 0;
        while (left < right)
        {
            int h = min(height[left], height[right]);
            ret = max(ret, (right - left) * h);
            if (height[right] < height[left])
                right--;
            else
                left++;
        }

        return ret;
    }
};

int main()
{
    Solution s;
    vector<int> nums = { 1,8,6,2,5,4,8,3,7 };
    s.maxArea(nums);
    return 0;
}